home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / text_utl / parsed / selfile.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  1994-10-04  |  4.2 KB  |  151 lines

  1. VERSION 2.00
  2. Begin Form frmSelFile 
  3.    Caption         =   "Select Text File To Load"
  4.    ClientHeight    =   4635
  5.    ClientLeft      =   1515
  6.    ClientTop       =   840
  7.    ClientWidth     =   6285
  8.    Height          =   5070
  9.    Left            =   1440
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4635
  12.    ScaleWidth      =   6285
  13.    Top             =   480
  14.    Width           =   6435
  15.    Begin CommandButton cmdLoad 
  16.       Caption         =   "&Load File"
  17.       Height          =   375
  18.       Left            =   1815
  19.       TabIndex        =   2
  20.       Top             =   3840
  21.       Width           =   2340
  22.    End
  23.    Begin TextBox txtPattern 
  24.       Height          =   315
  25.       Left            =   435
  26.       TabIndex        =   6
  27.       Top             =   450
  28.       Width           =   2355
  29.    End
  30.    Begin TextBox txtFile 
  31.       Height          =   315
  32.       Left            =   420
  33.       TabIndex        =   7
  34.       Top             =   3420
  35.       Width           =   5115
  36.    End
  37.    Begin DriveListBox Drive1 
  38.       Height          =   315
  39.       Left            =   2940
  40.       TabIndex        =   5
  41.       Top             =   510
  42.       Width           =   2535
  43.    End
  44.    Begin DirListBox Dir1 
  45.       Height          =   1830
  46.       Left            =   2940
  47.       TabIndex        =   1
  48.       Top             =   1080
  49.       Width           =   2535
  50.    End
  51.    Begin FileListBox File1 
  52.       Height          =   2175
  53.       Left            =   450
  54.       TabIndex        =   0
  55.       Top             =   870
  56.       Width           =   1905
  57.    End
  58.    Begin Label Label2 
  59.       Caption         =   "Current File:"
  60.       Height          =   255
  61.       Left            =   450
  62.       TabIndex        =   4
  63.       Top             =   3120
  64.       Width           =   1755
  65.    End
  66.    Begin Label Label1 
  67.       Caption         =   "File Patterns:"
  68.       Height          =   255
  69.       Left            =   480
  70.       TabIndex        =   3
  71.       Top             =   90
  72.       Width           =   1290
  73.    End
  74. Option Explicit
  75. Sub cmdLoad_Click ()
  76.    Dim FileNam$, FileContents$, msg$
  77.    Dim FileLength&
  78.    Screen.MousePointer = HOURGLASS
  79.    'get file name and length of selected file
  80.    FileNam$ = Trim$(txtFile)
  81.    FileLength& = FileLen(FileNam$)
  82.    'bail if file too big
  83.    If FileLength& > 28000 Then
  84.       msg$ = "The file you selected is too large. Please try another file."
  85.       MsgBox msg$, MB_ICONINFORMATION
  86.       Screen.MousePointer = DEFAULT
  87.       File1.SetFocus
  88.    Else
  89.       'load file and put contents into txtFileContents on frmParse
  90.       FileContents$ = LoadFile$(Trim$(txtFile), FileLength&)
  91.       frmParse!txtFileContents = FileContents$
  92.       'display filename on frmParse
  93.       frmParse!lblFileName = FileNam$
  94.       'display file length info on frmParse
  95.       frmParse!lblFileLen = "Length of File: " & Format$(FileLength&, "##,###") & " bytes."
  96.       Unload Me
  97.    End If
  98. End Sub
  99. Sub Dir1_Change ()
  100.     File1.Path = Dir1.Path
  101. End Sub
  102. Sub Dir1_Click ()
  103.     txtFile.Text = ""
  104. End Sub
  105. Sub Drive1_Change ()
  106.     Dir1.Path = Drive1.Drive
  107. End Sub
  108. 'put single-clicked file into txtFile
  109. Sub File1_Click ()
  110.     Dim i%
  111.     For i = 0 To File1.ListCount - 1
  112.         If File1.Selected(i%) = True Then
  113.             If Right$(Dir1.Path, 1) = "\" Then
  114.                 txtFile = File1.Path & File1.List(i)
  115.             Else
  116.                 txtFile = File1.Path & "\" & File1.List(i)
  117.             End If
  118.             Exit For
  119.         End If
  120.     Next i
  121.     If txtFile <> "" Then
  122.         cmdLoad.SetFocus
  123.     End If
  124. End Sub
  125. 'load the double-clicked file
  126. Sub File1_DblClick ()
  127.     Dim i%
  128.     For i = 0 To File1.ListCount - 1
  129.         If File1.Selected(i%) = True Then
  130.             If Right$(Dir1.Path, 1) = "\" Then
  131.                 txtFile = File1.Path & File1.List(i)
  132.             Else
  133.                 txtFile = File1.Path & "\" & File1.List(i)
  134.             End If
  135.             Exit For
  136.         End If
  137.     Next i
  138.     If txtFile <> "" Then
  139.         cmdLoad_Click
  140.     End If
  141. End Sub
  142. Sub Form_Activate ()
  143.    Screen.MousePointer = DEFAULT
  144. End Sub
  145. Sub Form_Load ()
  146.     Drive1.Drive = Left$(App.Path, 3)
  147.     File1.Path = Dir1.Path
  148.     File1.Pattern = "*.txt"
  149.     txtPattern = File1.Pattern
  150. End Sub
  151.